<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/24
 * Time: 9:52
 */

pdo_query("
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_mendian` (
        `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `uniacid` int(10) unsigned NOT NULL,
        `displayorder` int(11) NOT NULL DEFAULT '0',
        `mdcate_id` int(10) NOT NULL COMMENT '种类id',
        `mendianname` varchar(200) NOT NULL COMMENT '门店名称',
        `thumb` varchar(200) DEFAULT NULL COMMENT '图片',
        `tuce` text COMMENT '图册',
        `tel` varchar(20) DEFAULT NULL COMMENT '电话',
        `address` varchar(200) DEFAULT NULL COMMENT '地址',
        `lng` varchar(10) DEFAULT NULL COMMENT '经度',
        `lat` varchar(10) DEFAULT NULL COMMENT '纬度',
        `province` varchar(200) DEFAULT NULL COMMENT '省',
        `city` varchar(200) DEFAULT NULL COMMENT '市',
        `dist` varchar(200) DEFAULT NULL,
        `town` varchar(200) DEFAULT NULL,
        `street` varchar(200) DEFAULT NULL,
        `manageid` int(10) NOT NULL DEFAULT '0' COMMENT '负责人id',
        `channelid` int(10) NOT NULL DEFAULT '0' COMMENT '渠道拓展商id',
        `starttime` varchar(30) DEFAULT NULL COMMENT '每天开始营业时间',
        `endtime` varchar(30) DEFAULT NULL COMMENT '每天结束营业时间',
        `description` text COMMENT '描述',
        `isbusine` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否正常营业',
        `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
        `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
        `updatetime` int(11) unsigned NOT NULL,
        `createtime` int(11) unsigned NOT NULL,
        `industryid` int(10) NOT NULL DEFAULT '0',
        `mdnumber` varchar(255) NOT NULL DEFAULT '0',
        `goodstax` decimal(4,2) NOT NULL DEFAULT '0.00',
        PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='门店表';
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_mendian_cate` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) NOT NULL,
          `displayorder` int(11) NOT NULL DEFAULT '0' COMMENT 'ForOrder',
          `name` varchar(255) NOT NULL,
          `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT 'ForLogoImage',
          `description` varchar(255) NOT NULL,
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_mendian_industry` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `displayorder` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'ForOrder',
          `platformid` int(11) unsigned NOT NULL DEFAULT '0',
          `name` varchar(255) NOT NULL,
          `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT 'ForLogoImage',
          `description` varchar(255) NOT NULL,
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
            
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_platform` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) NOT NULL,
          `displayorder` int(11) NOT NULL DEFAULT '0' COMMENT 'ForOrder',
          `name` varchar(255) NOT NULL,
          `thumb` varchar(255) NOT NULL DEFAULT '' COMMENT 'ForLogoImage',
          `description` varchar(255) NOT NULL,
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_mendian_bonus` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `industryid` int(11) unsigned NOT NULL,
          `tuijian` decimal(6,2) NOT NULL COMMENT '推荐奖',
          `tuijian2` decimal(6,2) NOT NULL COMMENT '推荐奖',
          `tuijian3` decimal(6,2) NOT NULL COMMENT '推荐奖',
          `xiaofei` decimal(6,2) NOT NULL COMMENT '消费者',
          `hangye` decimal(6,2) NOT NULL COMMENT '行业服务商',
          `shengji` decimal(6,2) NOT NULL COMMENT '省级运营商',
          `quyu` decimal(6,2) NOT NULL COMMENT '区域运营商',
          `jiangjin` decimal(6,2) NOT NULL COMMENT '会员大奖池',
          `gongsi` decimal(6,2) NOT NULL COMMENT '公司',
          `jishu` decimal(6,2) NOT NULL COMMENT '技术',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_notice` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) NOT NULL,
          `commission` text,
          `xiaofei` text,
          `tuijian` text,
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_operator` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `uniacid` int(11) unsigned NOT NULL,
        `displayorder` tinyint(3) unsigned NOT NULL DEFAULT '0',
        `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1省级 2区级',
        `uid` int(10) NOT NULL DEFAULT '0',
        `account` varchar(127) NOT NULL DEFAULT '' COMMENT '账号'
        `password` char(32) NOT NULL DEFAULT '' COMMENT '密码'
        `salt` varchar(32) NOT NULL DEFAULT '' COMMENT '加盐'
        `province` varchar(50) NOT NULL DEFAULT '0' COMMENT '省',
        `city` varchar(50) NOT NULL DEFAULT '0' COMMENT '市',
        `dist` varchar(50) NOT NULL DEFAULT '0' COMMENT '区',
        `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
        `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
        `createtime` int(11) unsigned NOT NULL,
        `updatetime` int(11) unsigned NOT NULL,
        PRIMARY KEY (`id`),
        KEY `op_uid` (`uid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='运营商表';
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_commission` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `uid` int(11) unsigned NOT NULL DEFAULT '0',
          `mendianid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店佣金',
          `type` tinyint(2) unsigned NOT NULL DEFAULT '1' COMMENT '1个人2门店',
          `total` decimal(12,2) NOT NULL COMMENT '总收入佣金',
          `remain` decimal(12,2) NOT NULL COMMENT '剩余佣金',
          `drawal` decimal(12,2) NOT NULL COMMENT '提现佣金',
          `freeze` decimal(12,2) NOT NULL COMMENT '申请提现冻结金额',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`),
          KEY `uid` (`uid`)
        ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='cgc佣金表';
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_commission_log` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `uniacid` int(11) unsigned NOT NULL,
        `orderid` int(11) unsigned NOT NULL,
        `withid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '提现id',
        `comid` int(11) unsigned NOT NULL COMMENT '佣金id',
        `uid` int(11) unsigned NOT NULL DEFAULT '0',
        `mendianid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店id',
        `type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1收入佣金2提现佣金',
        `money` decimal(12,2) NOT NULL COMMENT '佣金',
        `ratio` decimal(6,2) NOT NULL DEFAULT '0.00' COMMENT '分红比例',
        `level` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1店主2创业者3渠道商4省运营商5区6推荐7消费',
        `isfinish` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否完成',
        `finishtime` int(11) unsigned NOT NULL,
        `description` varchar(255) DEFAULT NULL COMMENT '佣金描述',
        `createtime` int(11) unsigned NOT NULL,
        `iscredit` tinyint(1) unsigned NOT NULL DEFAULT '0',
        `ordersn` varchar(255) NOT NULL DEFAULT '0',
        PRIMARY KEY (`id`),
        KEY `orderid` (`orderid`),
        KEY `comid` (`comid`),
        KEY `uid` (`uid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_commission_reserved` (
        `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
        `uniacid` int(11) unsigned NOT NULL,
        `jishu` decimal(12,2) NOT NULL COMMENT '技术',
        `jiangjin` decimal(12,2) NOT NULL COMMENT '奖金池',
        `remain` decimal(12,2) NOT NULL COMMENT '遗留金额',
        `createtime` int(11) unsigned NOT NULL,
        `updatetime` int(11) unsigned NOT NULL,
        `gongsi` decimal(12,2) NOT NULL DEFAULT '0.00',
        PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
      CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_commission_reserved_log` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `uniacid` int(11) unsigned NOT NULL,
        `orderid` int(11) unsigned NOT NULL,
        `jishu` decimal(12,2) NOT NULL COMMENT '技术',
        `jiangjin` decimal(12,2) NOT NULL COMMENT '奖金池',
        `remain` decimal(12,2) NOT NULL COMMENT '遗留金额',
        `type` tinyint(1) unsigned NOT NULL COMMENT '1收入2支出',
        `description` varchar(255) NOT NULL COMMENT '描述',
        `createtime` int(11) unsigned NOT NULL,
        `gongsi` decimal(12,2) NOT NULL DEFAULT '0.00',
        `ordersn` varchar(255) NOT NULL DEFAULT '0',
        PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=106 DEFAULT CHARSET=utf8 COMMENT='预留佣金记录';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `displayorder` smallint(5) unsigned NOT NULL DEFAULT '0',
          `docking_number` varchar(255) NOT NULL COMMENT '编号',
          `password` varchar(50) NOT NULL,
          `name` varchar(100) NOT NULL,
          `thumb` varchar(255) NOT NULL,
          `description` text NOT NULL COMMENT '描述',
          `brands_id` int(11) unsigned NOT NULL COMMENT '设备品牌id',
          `type_id` int(11) unsigned NOT NULL COMMENT '设备种类id',
          `mendian_id` int(11) unsigned NOT NULL COMMENT '门店id',
          `isnormal` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '工作状态',
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          PRIMARY KEY (`id`),
          KEY `brands_id` (`brands_id`),
          KEY `type_id` (`type_id`),
          KEY `mendian_id` (`mendian_id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_brands` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `displayorder` smallint(5) unsigned NOT NULL DEFAULT '0',
          `name` varchar(100) NOT NULL,
          `logo` varchar(255) NOT NULL COMMENT '品牌logo',
          `description` text COMMENT '描述',
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备品牌表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_order` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `ordersn` varchar(255) NOT NULL,
          `uid` int(11) unsigned NOT NULL DEFAULT '0',
          `typeid` int(10) unsigned NOT NULL COMMENT 'goodstypeid',
          `number` int(10) unsigned NOT NULL DEFAULT '1',
          `md_number` varchar(255) NOT NULL DEFAULT '0' COMMENT '门店编号',
          `province` varchar(255) NOT NULL DEFAULT '0',
          `city` varchar(255) NOT NULL DEFAULT '0',
          `dist` varchar(255) NOT NULL DEFAULT '0',
          `address` varchar(255) NOT NULL DEFAULT '0',
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `isclose` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `closetime` int(11) unsigned NOT NULL DEFAULT '0',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `deletetime` int(11) unsigned NOT NULL DEFAULT '0',
          `finishtime` int(11) unsigned NOT NULL DEFAULT '0',
          `createtime` int(11) unsigned NOT NULL,
          `mobile` varchar(20) NOT NULL DEFAULT '0',
          `realname` varchar(255) NOT NULL DEFAULT '0',
          `goodsprice` decimal(12,2) NOT NULL DEFAULT '0.00',
          `realprice` decimal(12,2) NOT NULL DEFAULT '0.00',
          `mendian_id` int(10) NOT NULL DEFAULT '0',
          `weixin` varchar(150) NOT NULL DEFAULT '0',
          `contract` text,
          `contracttime` int(11) NOT NULL DEFAULT '0',
          `updatetime` int(11) NOT NULL DEFAULT '0',
          `clearprice` decimal(12,2) NOT NULL DEFAULT '0.00',
          PRIMARY KEY (`id`),
          KEY `cgc_uid` (`uid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_owner` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `goods_id` int(11) unsigned NOT NULL COMMENT '设备id',
          `uid` int(11) unsigned NOT NULL DEFAULT '0',
          `ratio` decimal(6,2) NOT NULL COMMENT '占有比例',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `updatetime` int(11) unsigned NOT NULL,
          `createtime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`),
          KEY `goods_id` (`goods_id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备创业者表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_type` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `displayorder` smallint(5) unsigned NOT NULL DEFAULT '0',
          `name` varchar(100) NOT NULL COMMENT '种类名称',
          `logo` varchar(255) NOT NULL,
          `description` text NOT NULL,
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `goodsprice` decimal(12,2) NOT NULL DEFAULT '0.00',
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备种类表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_type_bonus` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `type_id` int(11) unsigned NOT NULL COMMENT '设备种类id',
          `chuangye` decimal(6,2) NOT NULL COMMENT '创业者比例',
          `dianzhu` decimal(6,2) NOT NULL COMMENT '店主',
          `shengji` decimal(6,2) NOT NULL COMMENT '省级运营商',
          `quyu` decimal(6,2) NOT NULL COMMENT '区域运营商',
          `qudao` decimal(6,2) NOT NULL COMMENT '渠道开拓商',
          `tuijian` decimal(6,2) NOT NULL COMMENT '推荐',
          `xiaofei` decimal(6,2) NOT NULL COMMENT '消费者',
          `jishu` decimal(6,2) NOT NULL COMMENT '技术',
          `jiangjin` decimal(6,2) NOT NULL COMMENT '奖金',
          `updatetime` int(11) unsigned NOT NULL,
          `tuijian2` decimal(6,2) NOT NULL DEFAULT '0.00',
          `tuijian3` decimal(6,2) NOT NULL DEFAULT '0.00',
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备种类分红设置表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_type_price` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `type_id` int(11) unsigned NOT NULL COMMENT '设备种类id',
          `usetime` mediumint(7) unsigned NOT NULL COMMENT '服务时间',
          `price` decimal(12,2) NOT NULL COMMENT '价格',
          `market_price` decimal(12,2) NOT NULL COMMENT '市场价格',
          `integral` int(11) unsigned NOT NULL COMMENT '赠送积分',
          `most_reduce_price` int(11) unsigned NOT NULL COMMENT '积分抵扣金额',
          `description` text,
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `updatetime` int(11) unsigned NOT NULL,
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `name` varchar(255) NOT NULL DEFAULT '0',
          `thumb` varchar(255) NOT NULL DEFAULT '0',
          PRIMARY KEY (`id`),
          KEY `type_id` (`type_id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='设备种类价格套餐表';
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_order` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `uid` int(10) unsigned NOT NULL DEFAULT '0',
          `ordersn` varchar(30) NOT NULL COMMENT '订单号',
          `goods_id` int(11) unsigned NOT NULL COMMENT '商品id',
          `goods_name` varchar(50) NOT NULL,
          `price_id` int(10) unsigned NOT NULL COMMENT '价格套餐id',
          `thumb` varchar(255) NOT NULL,
          `price` decimal(12,2) NOT NULL COMMENT '订单价格',
          `realprice` decimal(12,2) NOT NULL COMMENT '实付金额',
          `goodsprice` decimal(12,2) NOT NULL COMMENT '商品价格',
          `marketprice` decimal(12,2) NOT NULL COMMENT '市场价',
          `mendian_id` int(11) unsigned NOT NULL,
          `mendian_name` varchar(50) NOT NULL COMMENT '门店名称',
          `remark` varchar(255) DEFAULT NULL COMMENT '备注',
          `close_desc` varchar(255) DEFAULT NULL COMMENT '取消订单原因',
          `transid` varchar(50) NOT NULL DEFAULT '0',
          `paytype` tinyint(3) unsigned NOT NULL COMMENT '支付方式',
          `status` tinyint(1) unsigned NOT NULL DEFAULT '1',
          `upstatus` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '上一次状态',
          `ispay` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0未支付1已支付',
          `isrefund` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否申请退款',
          `apppay` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'app支付',
          `deductcredit` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '抵扣积分',
          `deductprice` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '抵扣金额',
          `iscomment` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否已评价',
          `commenttime` int(11) unsigned NOT NULL DEFAULT '0',
          `isrecycle` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '回收站',
          `recycletime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '回收时间',
          `restoretime` int(11) unsigned NOT NULL COMMENT '恢复时间',
          `deleted` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '后台删除',
          `userdeleted` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '用户删除',
          `createtime` int(11) unsigned NOT NULL,
          `deletetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '后台删除时间',
          `userdeletetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户删除时间',
          `paytime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
          `finishtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '完成时间',
          `canceltime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '取消订单时间',
          `refundtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '申请退款时间',
          `cancetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '退款通过时间',
          `opentime` int(11) NOT NULL DEFAULT '0',
          `isopen` tinyint(1) NOT NULL DEFAULT '1',
          `couponid` int(10) NOT NULL DEFAULT '0',
          `couponcredit` decimal(10,2) NOT NULL DEFAULT '0.00',
          PRIMARY KEY (`id`),
          KEY `uid` (`uid`),
          KEY `ordersn` (`ordersn`),
          KEY `goods_id` (`goods_id`),
          KEY `mendian_id` (`mendian_id`),
          KEY `price_id` (`price_id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_order_comment` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) NOT NULL DEFAULT '0',
          `orderid` int(11) NOT NULL DEFAULT '0',
          `goodsid` int(11) NOT NULL DEFAULT '0',
          `mendianid` int(11) NOT NULL,
          `uid` int(10) unsigned NOT NULL DEFAULT '0',
          `nickname` varchar(50) DEFAULT NULL,
          `level` tinyint(2) unsigned NOT NULL DEFAULT '5',
          `content` varchar(255) DEFAULT NULL,
          `images` text,
          `createtime` int(11) NOT NULL DEFAULT '0',
          `deleted` tinyint(3) NOT NULL DEFAULT '0',
          `deletetime` int(11) unsigned NOT NULL DEFAULT '0',
          `checked` tinyint(3) NOT NULL DEFAULT '0',
          PRIMARY KEY (`id`),
          KEY `idx_uniacid` (`uniacid`),
          KEY `idx_goodsid` (`goodsid`),
          KEY `uid` (`uid`),
          KEY `idx_createtime` (`createtime`),
          KEY `idx_orderid` (`orderid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_order_refund` (
          `id` int(11) NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) DEFAULT '0',
          `orderid` int(11) DEFAULT '0' COMMENT '订单id',
          `refundno` varchar(255) DEFAULT '' COMMENT '订单编号',
          `uid` int(10) unsigned NOT NULL DEFAULT '0',
          `price` varchar(255) DEFAULT '' COMMENT '退款金额',
          `reason` varchar(255) DEFAULT '' COMMENT '退款原因',
          `images` text COMMENT '图片',
          `content` text COMMENT '退款留言',
          `createtime` int(11) DEFAULT '0',
          `status` tinyint(3) NOT NULL DEFAULT '0' COMMENT '1完成',
          `refundtype` tinyint(3) DEFAULT '0' COMMENT '退款类型',
          `refundtime` int(11) DEFAULT '0' COMMENT '退款时间',
          `orderprice` decimal(10,2) DEFAULT '0.00' COMMENT '订单价格',
          `message` text COMMENT '驳回申请原因',
          `opname` varchar(50) DEFAULT NULL COMMENT '操作人',
          `optime` int(11) unsigned DEFAULT '0' COMMENT '操作时间',
          `endtime` int(11) DEFAULT '0' COMMENT '用户取消时间',
          `isclose` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1用户取消2后台驳回',
          PRIMARY KEY (`id`),
          KEY `idx_createtime` (`createtime`),
          KEY `idx_uniacid` (`uniacid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_paylog` (
          `plid` bigint(11) unsigned NOT NULL AUTO_INCREMENT,
          `type` varchar(20) NOT NULL,
          `uniacid` int(11) NOT NULL,
          `acid` int(10) unsigned NOT NULL,
          `uid` int(11) unsigned NOT NULL DEFAULT '0',
          `uniontid` varchar(50) NOT NULL,
          `tid` varchar(128) NOT NULL,
          `fee` decimal(10,2) NOT NULL,
          `status` tinyint(4) NOT NULL,
          `module` varchar(50) NOT NULL,
          `tag` varchar(2000) NOT NULL,
          `is_usecard` tinyint(3) unsigned NOT NULL,
          `card_type` tinyint(3) unsigned NOT NULL,
          `card_id` varchar(50) NOT NULL,
          `card_fee` decimal(10,2) unsigned NOT NULL,
          `encrypt_code` varchar(100) NOT NULL,
          PRIMARY KEY (`plid`),
          KEY `uid` (`uid`),
          KEY `idx_tid` (`tid`),
          KEY `idx_uniacid` (`uniacid`),
          KEY `uniontid` (`uniontid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_goods_sale_bonus` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `zhitui` decimal(6,2) NOT NULL COMMENT '直推奖',
          `qiye` decimal(6,2) NOT NULL COMMENT '联营企业',
          `hangye` decimal(6,2) NOT NULL COMMENT '行业服务商',
          `shengji` decimal(6,2) NOT NULL COMMENT '省级运营商',
          `quyu` decimal(6,2) NOT NULL COMMENT '区域运营商',
          `huiyuan` decimal(6,2) NOT NULL COMMENT '会员大奖池',
          `gongsi` decimal(6,2) NOT NULL COMMENT '公司',
          `jishu` decimal(6,2) NOT NULL COMMENT '技术',
          `createtime` int(11) unsigned NOT NULL,
          `updatetime` int(11) unsigned NOT NULL,
          `type_id` int(10) NOT NULL DEFAULT '0',
          PRIMARY KEY (`id`)
        ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
        
        CREATE TABLE IF NOT EXISTS `ims_mx_shop_service_withdrawal` (
          `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
          `uniacid` int(11) unsigned NOT NULL,
          `uid` int(11) unsigned NOT NULL DEFAULT '0',
          `mendianid` varchar(30) NOT NULL DEFAULT '0',
          `drawalsn` varchar(50) NOT NULL COMMENT '提现编号',
          `type` tinyint(3) unsigned NOT NULL COMMENT '提现方式',
          `realname` varchar(50) NOT NULL DEFAULT '0' COMMENT '姓名',
          `alipay` varchar(30) NOT NULL DEFAULT '0' COMMENT '支付宝账号',
          `bankname` varchar(30) NOT NULL DEFAULT '0' COMMENT '银行名称',
          `bankcard` varchar(30) NOT NULL DEFAULT '0' COMMENT '银行卡号',
          `money` decimal(12,2) NOT NULL COMMENT '提现佣金',
          `realmoney` decimal(12,2) NOT NULL COMMENT '实际金额',
          `tax` decimal(4,2) NOT NULL COMMENT '个人税',
          `taxmoney` decimal(12,2) NOT NULL COMMENT '税金额',
          `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '1未审核2待打款3已打款4失效',
          `checktime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '审核时间',
          `paytime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '支付时间',
          `invalidtime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '无效时间',
          `refusetime` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '驳回时间',
          `reason` varchar(255) NOT NULL DEFAULT '0' COMMENT '失败原因',
          `createtime` int(11) unsigned NOT NULL,
          PRIMARY KEY (`id`),
          KEY `uid` (`uid`),
          KEY `mendianid` (`mendianid`)
        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

");

if(pdo_tableexists('mx_shop_mendian')) {
    if (!pdo_fieldexists('mx_shop_mendian', 'mdcode')) {
        pdo_query("ALTER TABLE " . tablename('mx_shop_mendian') . " ADD `mdcode` varchar(18) NOT NULL DEFAULT '';");
    }

    /* 支付 */
    if (!pdo_fieldexists('mx_shop_mendian', 'isinpay')) {
        pdo_query("ALTER TABLE " . tablename('mx_shop_mendian') . " ADD `isinpay` tinyint(1) NOT NULL DEFAULT '0';");
    }
    if (!pdo_fieldexists('mx_shop_mendian', 'serviceratio')) {
        pdo_query("ALTER TABLE " . tablename('mx_shop_mendian') . " ADD `serviceratio` decimal(4,2) NOT NULL DEFAULT '0';");
    }
    if (!pdo_fieldexists('mx_shop_mendian', 'payratio')) {
        pdo_query("ALTER TABLE " . tablename('mx_shop_mendian') . " ADD `payratio` decimal(4,2) NOT NULL DEFAULT '0';");
    }
}

